{% import 'admin/layout.html' as layout with context -%}
{% import 'admin/static.html' as admin_static with context %}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="">

        <title>{% block title %}{% if admin_view.category %}{{ admin_view.category }} - {% endif %}{{ admin_view.name }} - {{ admin_view.admin.name }}{% endblock %}</title>

        <!-- Bootstrap Core CSS -->
        <link href="{{url_for('static',filename='css/bootstrap.min.css')}}" rel="stylesheet">

        <!-- MetisMenu CSS -->
        <link href="{{url_for('static',filename='css/metisMenu.min.css')}}" rel="stylesheet">

        <!-- Custom CSS -->
        <link href="{{url_for('static',filename='css/startmin.css')}}" rel="stylesheet">

        <!-- Custom Fonts -->
        <link href="{{url_for('static',filename='css/font-awesome.min.css')}}" rel="stylesheet" type="text/css">

        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
        {% block head %}
        {% endblock %}
        {% block head_tail %}
        {% endblock %}
    </head>
    <body>
        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        {% block page_body %}
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>

                <ul class="nav navbar-nav navbar-left navbar-top-links">
                    <li><a href="#"><i class="fa fa-home fa-fw"></i> {{admin_view.admin.name }}</a></li>
                </ul>

                <ul class="nav navbar-right navbar-top-links">
                    <li class="dropdown">
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <i class="fa fa-user fa-fw"></i> {{ current_user.email }} <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="{{ url_for('security.logout') }}"><i class="fa fa-sign-out fa-fw"></i> Logout</a>
                            </li>
                        </ul>
                    </li>
                </ul>
                <!-- /.navbar-top-links -->


            {% block brand %}
<!--                <a class="navbar-brand" href="{{ admin_view.admin.url }}">{{ admin_view.admin.name }}</a>-->
            {% endblock %}
            {% block main_menu %}
                <div class="navbar-default sidebar" role="navigation">
                    <div class="sidebar-nav navbar-collapse">
                        <ul class="nav" id="side-menu">
                                {{ layout.menu() }}
                                <!-- /input-group -->
                        </ul>
                    </div>
                </div>

<!--                <ul class="navbar-nav mr-auto">-->
<!--                    {{ layout.menu() }}-->
<!--                </ul>-->
            {% endblock %}
</nav>
<!--            {% block access_control %}-->
<!--            {% endblock %}-->
<!--            </div>-->
<!--        </nav>-->

<!--        {% block messages %}-->
<!--            {{ layout.messages() }}-->
<!--        {% endblock %}-->
        <div id="page-wrapper" style="padding-top:80px;">
        {% block body %}
        {% endblock %}
        </div>
<!--    </div>-->
{% endblock %}
        <!-- jQuery -->
        <script src="{{url_for('static',filename='js/jquery.min.js')}}"></script>

        <!-- Bootstrap Core JavaScript -->
        <script src="{{url_for('static',filename='js/bootstrap.min.js')}}"></script>

        <!-- Metis Menu Plugin JavaScript -->
        <script src="{{url_for('static',filename='js/metisMenu.min.js')}}"></script>

        <!-- Custom Theme JavaScript -->
        <script src="{{url_for('static',filename='js/startmin.js')}}"></script>
        <script src="{{url_for('static',filename='js/wangEditor.min.js')}}"></script>
        <script>
        function Select_File(btn){
            $(btn).siblings('.file_box').click();
            $('.file_box').change(function(){
                var this_file = $(this)[0].files[0]
                $(this).siblings('.alert-success').find('span').html(this_file.name+',请点击Upload按钮进行上传')
            })
        }
        function Upload(btn,name){
            var this_file = $(btn).siblings(".file_box")[0].files[0]
            var __this = $(btn)
            var formData = new FormData();
            console.log(name)
            if(this_file){
                formData.set("images", $(btn).siblings('.file_box')[0].files[0]);
		        $.ajax({
                        type: "POST",
                        url: "/upload",
                        data: formData,
                        async: true,
                        processData: false,
                        contentType: false,
                        success:function(reData){
                            if(reData.status == "success"){
                                    var web_host = location.origin
                                    __this.parents().siblings('.form-group').find('#'+name).val(reData.file_path)
                            }
                        }
                    });
            }

        }


        </script>
    </body>
</html>

